﻿using System;
using System.Diagnostics.Contracts;
using System.IO;
using OpenLS.Spreadsheet.Formats.Biff.Records;

namespace OpenLS.Spreadsheet.Formats.Biff.OfficeArt
{
    internal class OfficeArtClientTextbox: OfficeArtRecord
    {
        public OfficeArtClientTextbox(Comment comment, OfficeArtWriteContext context)
        {
            Contract.Requires(comment != null);
            Contract.Requires(comment.Text != null);
            this.TxoRecord = new TxORecord(comment.Text, context);
        }

        public OfficeArtClientTextbox()
        {
        }

        public override RecType RecordType
        {
            get { return RecType.OfficeArtClientTextbox; }
        }

        protected override void PostReadNoHeader(OfficeArtReadContext context)
        {
            this.TxoRecord = context.GetTxoRecord((int)context.BaseStream.Position);
        }

        internal TxORecord TxoRecord { get; set; }


        protected override void ReadNoHeader(OfficeArtReadContext context)
        {
            Contract.Assert(rhrecVer == 0x0);
            Contract.Assert(rhrecInstance == 0x0);
            Contract.Assert(rhrecType == (RecType) 0xF00D);
        }

        protected override byte Version
        {
            get { return 0; }
        }

        protected override int ByteLength
        {
            get { return 0; }
        }


        protected override void WriteNoHeader(OfficeArtWriteContext context)
        {
            Contract.Assert(rhrecVer == 0x0);
            Contract.Assert(rhrecInstance == 0x0);
            Contract.Assert(rhrecType == (RecType)0xF00D);
            Contract.Assert(this.TxoRecord != null);
            context.AddEmbeddedTxoRecord(this.TxoRecord);
        }

        protected override void PrepareHeader(ref OfficeArtRecordHeader rh)
        {
        }
    }
}